package testclient.com.aceitunaproject.testclient;

import com.aceitunaproject.clientinterface.AceitunaClientInterface;
import com.aceitunaproject.clientinterface.AceitunaClientInterfaceImpl;
import com.aceitunaproject.shared.message.concrete.MapAreaRefreshEvent;

/**
 * @author Federico Bergstein
 * 
 *         Quick and dirty class to test the aceituna client interface
 * 
 */
public class Main implements com.aceitunaproject.clientinterface.eventregistering.MapAreaRefreshHandler {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		new Main();

	}

	private boolean runFlag = true;

	public Main() {
		AceitunaClientInterface clientInterface = new AceitunaClientInterfaceImpl(
				"Fede");
		clientInterface.registerToEvent(this);
		clientInterface.login();
		// 
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		clientInterface.sendMessage(new MapAreaRefreshEvent());

		do {
			try {
				Thread.sleep(10000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} while (runFlag);

	}


	public void MapAreaRefresh(MapAreaRefreshEvent message) {
		System.out.print("message received from server, message type :"
				+ message.getMessageType());
		runFlag = false;
		
	}

}
